package com.ydl.learning.flink.demo.transformations

import com.ydl.learning.flink.demo.Utils
import org.apache.flink.api.scala._

/**
 * distinct
 *
 * @author ydl
 * @since 2020/10/12
 */
object DistinceDemo extends App with Utils {
  val input = env.fromElements((1, 2), (1, 2), (2, 2), (1, 4), (2, 3))
  //去重，不保证元素顺序
  input.distinct().print()
  //distinct可带参数，指定具体按哪个字段去重
  input.distinct(1).print()
  //自定义去重函数
  input.distinct(x => (x._2 % 2) == 0).print()
}
